<template>
    <!-- 提示  -->
    <div class="form-block">
        <label>提示<i class="iconfont icon-feedback_fill"></i></label>
        <div class="input-textarea textarea">
            <textarea placeholder="请输入描述，1000个字以内" v-model="description" @keyup="saveSetting"></textarea>
            <span class="tip">0/1000</span>
        </div>
    </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      description: ""
    };
  },

  mounted() {
      this.description = this.setting[this.currSettingId].description;
  },

  computed: {
    ...mapState(["currSettingId", "setting"])
  },

  methods: {
    ...mapMutations(["SET_SETTING_INFO"]),

    saveSetting() {
      this.SET_SETTING_INFO({
        id: this.currSettingId,
        description: this.description
      });
    }
  },
  watch: {
    currSettingId() {
      this.description = this.setting[this.currSettingId].description;
    }
  }
};
</script>
